import { createApp } from 'vue';
import App from './App.vue';
import { createPinia } from 'pinia';

import 'element-plus/dist/index.css';
import zhCn from "element-plus/es/locale/lang/zh-cn";
import ElementPlus from "element-plus";

import * as ElementPlusIconsVue from '@element-plus/icons-vue';

import XcForm from '@xc-components/xc-form';
import XcTable from '@xc-components/xc-table';

const app = createApp(App);

// 正确的注入顺序：在创建app之后
app.provide("iconPrefix", "i");

const pinia = createPinia();
app.use(pinia);

// 统一注册所有 Element Plus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

app.use(ElementPlus, { locale: zhCn });

app.component('XcForm', XcForm);
app.component('XcTable', XcTable);

app.mount('#app');
